void sensorStr(String *aStr) {
  String c = "";
  char2Str(data_str, &c);
  *aStr = c + comma + String(p) + comma + String(p_int) + comma + String(v_int);
  *aStr += comma + String(bma180.x_accel) + comma + String(bma180.y_accel) + comma + String(bma180.z_accel);
  *aStr += comma + String(fet1_monitor) + comma + String(fet2_monitor);
}


void statusStr(String *aStr) {
  String c = "";
  char2Str(sts_str, &c);
  *aStr = c + comma + String(millis()) + comma + String(mode) + comma + String(p_int);
  
  unsigned int bits = 0;
  unsigned int m = 0x01;
  if (fet1_on) bits += m; 
  m = m << 1;
  if (fet2_on) bits += m; 
  m = m << 1;
  if (led_on) bits += m; 
  m = m << 1;
  if (fet_go) bits += m; 
  m = m << 1;
  if (launch_hold) bits += m; 
  m = m << 1;
  if (chute_open) bits += m; 
  m = m << 1;
  if (test_mode) bits += m; 
  m = m << 1;
  if (arm_mode) bits += m; 
  m = m << 1;
  if (gps.get_age() < gps_valid_age) bits += m; 
  m = m << 1;
  //if (gpsInitialized) bits |= m; 
  m = m << 1;
  if (do_stage) bits += m; 
  m = m << 1;
  if (do_deploy) bits += m; 
  m = m << 1;
  if (do_main) bits += m; 
  m = m << 1;
  if (do_record) bits += m; 
  m = m << 1;
  
  *aStr += comma + String(bits);
}

void settingsStr(String *aStr) {
  String c = "";
  char2Str(set_str, &c);
  *aStr = c + comma + String(p_deploy) + comma + String (p_launch) + comma + String(p_stage);
  *aStr += comma + String(pv_stage) + comma + String(h_deploy) + comma + String(h_launch);
  *aStr += comma + String(h_stage) + comma + String(v_stage) + comma + String(site_alt);
}

void flightStr(String *aStr) {
  String c = "";
  char2Str(flight_str, &c);
  *aStr = c + comma + String(cal_time) + comma + String(launch_time) + comma + String(flight_time);
  *aStr += comma + String(stage_time) + comma + String(deploy1_time) + comma + String(deploy2_time);
  *aStr += comma + String(p_min) + comma  + String(p_site) + comma + String(site_alt);
}

void gpsString(String *aStr) {
  String c = "";
  char2Str(gps_str, &c);
  *aStr = c + comma + String(gps.lat) + comma;
  *aStr += String(gps.lon) + comma + String(gps.alt) + comma;
  *aStr += String(gps.get_age()) + comma + String(p_int);
}

void char2Str(char c[], String *s) {
  *s = String(c[0]);
  *s += String(c[1]);
}
